function createStore(initState) {
  const state = initState || {};
  const list = [];
  return {
    getState() {
      return state;
    },
    dispatch({ type, value }) {
      state[type] = value;
      list.length && list.forEach((fn) => fn());
    },
    subscribe(fn) {
      list.push(fn);
    },
  };
}
